﻿using System;
using Luna.Model.Common;

namespace Luna.Data
{
    /// <summary>
    /// Generator for data interface IReferenceData.
    /// </summary>
    public partial class Manager
    {
        public void Load(Luna.Data.Common.IReferenceData data)
        {
            data.PK = Generator.GetGuid();
            data.LastUpdate = Generator.GetDateAndTime();
            data.Google = Generator.GetString(32);
            data.GoogleLastUpdate = Generator.GetNullableDateAndTime();
            data.ZohoCRM = Generator.GetNullableInteger();
            data.ZohoCRMLastUpdate = Generator.GetNullableDateAndTime();
            data.From = Generator.GetEnum<ProviderType>();
            data.Validated = Generator.GetBoolean();
        }

        public bool AreSame(Luna.Data.Common.IReferenceData data1, Luna.Data.Common.IReferenceData data2)
        {
            bool buffer = true;

            buffer &= data1.PK == data2.PK;
            buffer &= data1.LastUpdate == data2.LastUpdate || data1.LastUpdate - data2.LastUpdate < TimeSpan.FromMilliseconds(3);
            buffer &= data1.Google == data2.Google;
            buffer &= data1.GoogleLastUpdate == data2.GoogleLastUpdate || data1.GoogleLastUpdate - data2.GoogleLastUpdate < TimeSpan.FromMilliseconds(3);
            buffer &= data1.ZohoCRM == data2.ZohoCRM;
            buffer &= data1.ZohoCRMLastUpdate == data2.ZohoCRMLastUpdate || data1.ZohoCRMLastUpdate - data2.ZohoCRMLastUpdate < TimeSpan.FromMilliseconds(3);
            buffer &= data1.From == data2.From;
            buffer &= data1.Validated == data2.Validated;
            return buffer;
        }
    }
}